from typing import List


class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        """
        地址：https://leetcode-cn.com/problems/two-sum/

        :param nums:
        :param target:
        :return:
        """
        # map: key -> 输入的整数，value -> 数组下标
        tmp_map = dict()
        for index, num in enumerate(nums):
            ano_num = target - num  # 期望的另一个整数
            if tmp_map.get(ano_num) is not None:
                return [tmp_map[ano_num], index]
            tmp_map[num] = index  # (当前整数，下标)


if __name__ == '__main__':
    solution = Solution()
    print(solution.twoSum([2, 7, 11, 15], 9))
    print(solution.twoSum([3, 2, 4], 6))
    print(solution.twoSum([3, 3], 6))
